﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IOTest
{
    class Program
    {
        static void Main(string[] args)
        {
            //在D盘根目录下创建MySolo文件夹
            bool flag = Directory.Exists("D:\\mySolo");
            if (flag)
            {
                Directory.Delete("D:\\mySolo",true);
            }
            else
            {
                Directory.CreateDirectory("D:\\mySolo");
            }

            //在mySolo文件夹下创建test.txt文件
            FileInfo file = new FileInfo("D:\\mySolo\\test.txt");

            //写入内容
            string path = @"D:\\mySolo\\test.txt";
            //创建StreamWriter类的实例
            StreamWriter streamWriter = new StreamWriter(path);
            //向文件中写入姓名
            streamWriter.WriteLine("黄炎榕");
            //向文件中写入年龄
            streamWriter.WriteLine(19);
            //刷新缓存
            streamWriter.Flush();
            //关闭流
            streamWriter.Close();

        }
    }
}
